package com.rtline.business.model;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.rtline.business.vo.OrderVo;

import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;


/**
 * <p>OrderEntity .
 *
 * <p>change history:
 *
 * <pre>
 * date         defect       person          comments
 * --------------------------------------------------------------------------------
 * 2025/6/1    ********     Tao Ren    create file.
 * </pre>
 *
 * @author Tao Ren
 * @date 2025/6/1 18:07
 */
@Data
@TableName("order") // 指定表名
@AutoMapper(target = OrderVo.class) // 重点 （MapStruct Plus 新增的注解）
public class OrderEntity extends Model<OrderEntity> {

    @TableId(type = IdType.AUTO) // 主键ID，自增
    private Long id;

    @TableField("user_id") // 指定字段名
    private Long userId;

    @TableField("order_status") // 指定字段名
    private String orderStatus;

    @TableField("total_amount") // 指定字段名
    private BigDecimal totalAmount;

    @TableField(value = "created_at", fill = FieldFill.INSERT) // 指定字段名，插入时自动填充
    private LocalDateTime createdAt;

    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE) // 指定字段名，插入和更新时自动填充
    private LocalDateTime updatedAt;

    // 省略getter和setter方法

    @Override
    public String toString() {
        return "Order{" +
                "id=" + id +
                ", userId=" + userId +
                ", orderStatus='" + orderStatus + '\'' +
                ", totalAmount=" + totalAmount +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                '}';
    }
}
